package Card;

import java.util.ArrayList;
import java.util.Random;

public class Demo {
    public static final String[] suits = {"♥","♠","♣","♦"};

    public ArrayList<Card> cardList;

    public Demo() {
        cardList = new ArrayList<>();
    }

    //买牌
    public void buyCard() {
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < suits.length; j++) {
                Card card = new Card(i, suits[j]);
                cardList.add(card);
            }
        }
    }

    //洗牌
    public void shuffle() {
        Random random = new Random();
        for (int i = cardList.size() - 1; i > 0; i--) {
            int ret = random.nextInt(i);
            swap(i, ret);
            //swap(cardList.get(i), cardList.get(ret));
        }
    }

    //交换两张牌
//    public void swap(Card card1, Card card2) {
//        Card temp = new Card();
//        temp = card1;
//        card1 = card2;
//        card2 = temp;
//    }

    //交换两张牌
    public void swap(int i, int j) {
        Card card = new Card();
        card = cardList.get(i);
        cardList.set(i, cardList.get(j));
        cardList.set(j, card);
    }

    //展示所有牌
    public void showAllCard() {
        int n = 0;
        for (Card card : cardList) {
            if (n % 10 == 0) {
                System.out.println();
            }
            System.out.print(card + " ");
            n++;
        }
        System.out.println();
    }

    //展示每个人的牌
    public void showCard(ArrayList<Card> cardList) {
        for (Card card : cardList) {
            System.out.print(card + " ");
        }
        System.out.println();
    }
}
